<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class TextHandler extends WechatHandler {

    public function run($Content) {

        if ("getopenid" == $Content) {
            $this->wc->responseText($this->openID);
        }

        if ("tx1" == $Content) {
            $this->wc->echoGmess(38);
        }

        // 系统定义自动回复
        $Rep = $this->wc->Db->query("SELECT * FROM `wechat_autoresponse`;");
        foreach ($Rep as $rep) {
            if ($Content == $rep['key']) {
                if ($rep['rel'] != 0) {
                    $this->wc->echoGmess($rep['rel']);
                } else {
                    $this->wc->responseText($rep['message']);
                }
            }
        }
    }

}
